package main

import (
	"fmt"
	"gitee.com/injoyai/goutil/string/logs"
	"github.com/injoyai/lorca"
	"time"
)

func main() {
	logs.PrintErr(lorca.Run(&lorca.Config{
		Html: `
	<!doctype html>
	<html>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<head>
			<title>Hello</title>
			<link rel="shortcut icon" href="/ico.jpg" >
		</head>
		
		<body>
			<h1>Hello, world!</h1>
			<pre id="pre"></pre>
			<button onclick="bt()">按钮</button>
		</body>

		
		
	</html>`,
	}, func(ui lorca.UI) error {

		ui.Bind("bt", func() {
			ui.Eval(fmt.Sprintf("pre.innerText = '%s'", time.Now().Format("2006-01-02 15:04:05")))
		})

		//ui.Bind()
		for {
			time.Sleep(time.Second)
			//ui.Eval(fmt.Sprintf("pre.innerText = '%s'", time.Now().Format("2006-01-02 15:04:05")))
		}

		return nil
	}))
}
